/*
 * @Author: TianyiWang
 * @Date: 2022-06-13 12:20:03
 * @LastEditors: TianyiWang
 * @LastEditTime: 2022-06-13 12:26:05
 * @Description: file content
 * @FilePath: /TinyWebServer/home/wty/sylar_learn/sylar/singleton.h
 */
#ifndef __SYLAR_SINGLETON_H__
#define __SYLAR_SINGLETON_H__
#include<memory>

namespace sylar{

/**
 * @brief 单例模式封装类
 * @details T 类型
 *          X 为了创造多个实例对应的Tag
 *          N 同一个Tag创造多个实例索引
 */
template<class T, class X = void, int N = 0>
class Singleton {
public:
    // 返回单例裸指针
    static T* GetInstance() {
        static T v;
        return &v;
    }
};

template<class T, class X = void, int N = 0>
class SingletonPtr {
public:
    static std::shared_ptr<T> GetInstance() {
        static std::shared_ptr<T> v(new T);
        return v;
    }
};

}

#endif